package com.dq.fileIO;

import java.io.FileInputStream;  
import java.io.FileOutputStream;  
import java.io.IOException;  

class IODemo  
{  
    public static void main(String[] args)   
    {  
        try  
        {  
        //使用FileInputStream和FileOutputStream进行文件复制  
        FileInputStream fis=new FileInputStream("a.txt");  
        FileOutputStream fos=new FileOutputStream("b.txt");  
            int read;  
            //read=fis.read();  
            byte b[]=new byte[1024];  
            //读取文件，存入字节数组b，返回读取到的字符数，存入read,默认每次将b数组装满  
            read=fis.read(b);  
            while(read!=-1)  
            {  
                fos.write(b,0,read);  
                read=fis.read(b);  
                //read=fis.read();  
            }  
            fis.close();  
            fos.close();  
        }  
        catch (IOException e)  
        {  
            e.printStackTrace();  
        }  
          
    }  
}  